package com.itheima.controller;

import com.itheima.entity.Result;
import com.itheima.resources.MessageConstant;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/user",name = "用户模块")
public class UserController {
    @RequestMapping(value = "/findUsername.do",name = "查询用户名")
    public Result findUsername(Authentication authentication){
        try {
            //获取用户名
            String name = authentication.getName();
            //返回用户名
            return new Result(true, MessageConstant.GET_MENU_SUCCESS,name);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(true, MessageConstant.GET_MENU_FAIL);
        }

    }
}
